package com.ruoyi.backstage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.zzw.domain.EventManage;
import com.ruoyi.zzw.service.TEventManageService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 事件管理Controller
 * 
 * @author ruoyi
 * @date 2023-12-06
 */
@RestController
@RequestMapping("/backstage/eventManage")
public class BackEventManageController extends BaseController
{
    @Autowired
    private TEventManageService tEventManageService;

    /**
     * 查询事件管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:event:list')")
    @GetMapping("/list")
    public TableDataInfo list(EventManage eventManage)
    {
        startPage();
        List<EventManage> list = tEventManageService.selectTEventManageList(eventManage);
        return getDataTable(list);
    }

    /**
     * 导出事件管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:event:export')")
    @Log(title = "事件管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EventManage eventManage)
    {
        List<EventManage> list = tEventManageService.selectTEventManageList(eventManage);
        ExcelUtil<EventManage> util = new ExcelUtil<EventManage>(EventManage.class);
        util.exportExcel(response, list, "事件管理数据");
    }

    /**
     * 获取事件管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:event:query')")
    @GetMapping(value = "/{cEventId}")
    public AjaxResult getInfo(@PathVariable("cEventId") Long cEventId)
    {
        return success(tEventManageService.selectTEventManageByCEventId(cEventId));
    }

    /**
     * 新增事件管理
     */
    @PreAuthorize("@ss.hasPermi('system:event:add')")
    @Log(title = "事件管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EventManage eventManage)
    {
        return toAjax(tEventManageService.insertTEventManage(eventManage));
    }

    /**
     * 修改事件管理
     */
    @PreAuthorize("@ss.hasPermi('system:event:edit')")
    @Log(title = "事件管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EventManage eventManage)
    {
        return toAjax(tEventManageService.updateTEventManage(eventManage));
    }

    /**
     * 删除事件管理
     */
    @PreAuthorize("@ss.hasPermi('system:event:remove')")
    @Log(title = "事件管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cEventIds}")
    public AjaxResult remove(@PathVariable Long[] cEventIds)
    {
        return toAjax(tEventManageService.deleteTEventManageByCEventIds(cEventIds));
    }
}
